package com.iccct.feign.controller;

import com.iccct.feign.common.Response;
import com.iccct.feign.model.ReservoirNews;
import com.iccct.feign.remote.IProviderService;
import com.iccct.feign.remote.IReservoirNewsService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * comment
 *
 * @author iccct (taowutt1@gmail.com)
 * @since 2021-07-28  14:24
 */
@RestController
@RequestMapping("/feign")
public class FeignController {

    @Resource
    private IProviderService providerService;

    @Resource
    private IReservoirNewsService reservoirNewsService;

    @Value("${spring.application.name}")
    private String name;


    @PostMapping("/echo")
    public Map<String, Object> test(@RequestBody ReservoirNews reservoirNews){
        String echo = providerService.echo(name);
        Map<String, Object> map = new HashMap<>();
        //Response news = reservoirNewsService.findNews(reservoirNews);

        map.put("provider",echo);
        //map.put("news",news);
        return map;
    }
}
